#ifndef OCK_ACLADAPTER_OCK_TASK_RESOURCE_TYPE_H
#define OCK_ACLADAPTER_OCK_TASK_RESOURCE_TYPE_H

#include <ostream>
#include "ock/hmm/mgr/OckHmmHeteroMemoryLocation.h"
#include <cstdint>
#include <ostream>
#include <limits>
#include <unordered_map>
namespace ock {
namespace acladapter {

enum class OckTaskResourceType : uint32_t {
    MEMORY_TRANSFER = 1U,
    DEVICE_MEMORY_OP = 2U,
    HOST_MEMORY_OP = 4U,
    MEMORY_OP = DEVICE_MEMORY_OP | HOST_MEMORY_OP,
    HMM = MEMORY_OP | MEMORY_TRANSFER,
    DEVICE_AI_CUBE = 8U,
    DEVICE_AI_VECTOR = 8U,
    DEVICE_AI_CPU = 8U,
    HOST_CPU = 8U,
    CPU = HOST_CPU | DEVICE_AI_CPU,
    OP_TASK = HMM | DEVICE_AI_CUBE | DEVICE_AI_VECTOR | DEVICE_AI_CPU | HOST_CPU | CPU,
    DEVICE_STREAM = 8U,
    OP_SYNC_TASK = OP_TASK | DEVICE_STREAM,
    ALL = std::numeric_limits<uint32_t>::max(),
};

inline OckTaskResourceType operator|(OckTaskResourceType lhs, OckTaskResourceType rhs)
{
    return static_cast<OckTaskResourceType>(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
}
inline OckTaskResourceType operator&(OckTaskResourceType lhs, OckTaskResourceType rhs)
{
    return static_cast<OckTaskResourceType>(static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs));
}

inline bool RhsInLhs(OckTaskResourceType lhs, OckTaskResourceType rhs)
{
    return static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs) == static_cast<uint32_t>(rhs);
}

using OckTaskThreadNumberMap = std::unordered_map<OckTaskResourceType, uint32_t>;
uint32_t CalcRelateThreadNumber(const OckTaskThreadNumberMap &taskNumberMap, OckTaskResourceType resourceType);

std::ostream &operator<<(std::ostream &os, OckTaskResourceType resourceType);
std::ostream &operator<<(std::ostream &os, const OckTaskThreadNumberMap &data);

}
}
#endif